<script setup lang="ts">
// import { useUser } from '@/stores/user'
import { useUser } from '@/stores/index'
import { storeToRefs } from 'pinia'
const store = useUser()
const { testToken, num } = storeToRefs(store)

// pinia  num 数据  点击按钮++   刷新页面保持原样
/*
  vue2持久化插件
     vuex-persistedstate
  vue3持久化插件
     pinia-plugin-persistedstate
     1:下载
     2：配制使用
        import persistedstate from 'pinia-plugin-persistedstate'
        pinia.use(persistedstate)
     3：模块内配制
        defineStore('模块名',()=>{},{
          persist:{
            paths:['字段名']
          }
        })


*/
</script>

<template>
  <div class="app-page">
    <h3>{{ testToken }}</h3>
    <button @click="store.setTestToken('abc')">修改testTOken</button>
    <hr />
    <h3>{{ num }}</h3>
    <button @click="store.setNum">点击++</button>
  </div>
</template>

<style lang="scss" scoped></style>
